Before you can use the code produced by Mac F2C, you must set up and build all of the required support libraries. There are also special rules that must be followed when using code produced by Mac F2C. The process and rules are slightly different for each compiler. These instructions are for setting up Mac F2C for use with Symantec C/C++ for PPC. Refer to other chapters for instructions on how to set things up for use with THINK C/C++ for 68K or Metrowerk’s CodeWarrior C/C++ compilers.
Users upgrading from earlier versions need to re-install all libraries, project files, and supporting files. All files, including library source code, have been updated in version 1.3.
All of the Symantec project files shipped with Mac F2C are for the Symantec Project Manager (SPM) version 8.0.3 (the version included with Release 4 of Symantec C++ for Power Mac v8). They cannot be opened by SPM v8.0. If you have v8.0, I (and Symantec) urge you to upgrade to 8.0.3 using the free updaters available at major archive sites.
Project files for SPM version 8.0.4 are included in the SPM Support folder in a folder called SPM 8.0.4 Project Files. If you replace all the SPM 8.0.3 project files distributed with Mac F2C with the corresponding ones appearing in the SPM 8.0.4 Project Files folder, you can then use the installer application to install Mac F2C for SPM 8.0.4. Please note that the v8.0.4 installation has been tested only against the pre-release 8.0.4d11 version of the SPM. There may be some differences between this pre-release version and the final 8.0.4 version of SPM. These potential changes could break either the installer application or the project files themselves. Use the 8.0.4 project files at your own risk. If required, I will release an update to Mac F2C once the final SPM 8.0.4 is released.
Setting Up Mac F2C Using the Installer
The easiest way to set up Mac F2C is to use the installer included with Mac F2C. This installer will only work correctly if you have System 7.5 (or higher) and have Symantec v8. If you do not meet both of these requirements, please follow the instructions for manual installation found in the following section.
The installer is stand-alone AppleScript application called Mac F2C Installer. To run the installer, simply double click on it, and answer the dialogs it presents. The installer will do the following:
• Create a folder called Mac F2C Support within the folder containing the Symantec Project Manager.
• Build the appropriate Mac F2C libraries.
• Move the built libraries to the Mac F2C Support folder.
• Copy the Mac F2C project models to Symantec’s (Project Models) folder.
• Translate and build the appropriate versions of the test application.
When the installer is finished, you will find completed test applications in the Test Project Δí folder. You should run these to verify correct operation of Mac F2C and its libraries. After that, you are ready to go. To compile translated FORTRAN code, simply open a new project in the Symantec Project Manager, select the appropriate version of Mac F2C project models, and add the translated files.
The remaining sections provide step-by-step instructions for installing Mac F2C manually, a more detailed description of how to test your Mac F2C installation, and additional information on using code generated by Mac F2C with Symantec Project Manager.
Setting Up Mac F2C Manually
Set up is a two step process. First you must build the libraries, and then you must move several files to their proper locations.
Step 1: Build all the libraries
The libraries of the Mac F2C distribution come without binaries, so you have to build them according to the following algorithm:
FOR the project files in the Mac F2C Libraries folder:
(1) libI77 PPC
(2) libF77 PPC
REPEAT the following steps:
(a) Double-click on the project file.
(b) In the Symantec Project Manager’s Build menu,
select the Build Library command.
(c) When finished, select the Remove Objects
command in the Build menu.
END REPEAT
Step 2: Move things to the recommended locations
For easiest and smoothest operation, the remaining files should be
installed as follows:
• Create a folder called Mac F2C Support inside the folder within the folder that contains the Symantec Project Manager (SPM) application.
• Drag the two static (XCOFF) library files in the folder Mac F2C Libraries (libI77 PPC.o and libF77 PPC.o; the same ones you just built in Step 1 above) to the Mac F2C Support folder that you just created.
WARNING: Do not place the source code for these libraries (found in the folders libF77 Sources and libI77 Sources) in the folder containing the Symantec Project Manager application or in any of it’s sub-folders). The source code for these libraries has name conflicts with Apple’s Universal Headers (e.g., a file called fp.h appears in both but the two are NOT equivalent files). Otherwise any of your code that #includes any of the conflicted files may inadvertently access the wrong file.
• The folder For '(Project Models)' contains two model project folders called SPM Mac F2C C Project and SPM Mac F2C C++ Project. Drag both folders to the (Project Models) folder located in the same folder as the SPM (if you don’t plan to use Mac F2C with the C++ compiler, you don’t need the SPM Mac F2C C++ Project folder).
Verifying Correct Operation of Mac F2C
The folder Test Project Δí contains the following files:
test.f -- a sample FORTRAN program.
F2Cmain.c -- the main program required to run programs produced by Mac F2C.
F2Cmain.cp -- the main program required to run programs produced by Mac F2C.
f2c.h -- an include file required to compile programs produced by Mac F2C.
test.c (C Output) -- what you should get when you translate the sample FORTRAN code files.
Test.PPC.π -- an SPM v8.0 project to run the sample C program.
test.cp (C++ Output) -- what you should get when you translate
the sample FORTRAN code files and select the C++ output option.
Test++.PPC.π -- an SPM v8.0 project to run the sample C++ program.
Test.68K.π and Test++.68K.π -- THINK project files to run the sample program.
Test++.*.µ -- CodeWarrior project files to run the sample program.
Translate the sample FORTRAN program Test.f simply by dragging it onto Mac F2C. Do not change any of the options (use Factory Defaults). Once you have done this you can compare it with Test.c (C Output) to verify that you got the same thing. If so, double click on the SPM project Test.PPC.π and run it to verify correct operation.
If you also plan to use Mac F2C C++ output with the Codewarrior, you can run a second test to verify correct operation with the C++ compiler. Start Mac F2C and in the C Options dialog, select C++ code. Do not change any of the other options. Translate Test.f. Compare it with Test.cp (C++ Output) to verify that you got the same thing. If so, double click on the SPM project Test++.PPC.π and run it to verify correct operation.
Using C Code Generated by Mac F2C
The C code produced by Mac F2C has the following compile and link requirements when used with Symantec C/C++ for PPC:
PPC version:
• the header file:
f2c.h
• the F2C libraries:
libI77 PPC.o
libF77 PPC.o
• the Symantec libraries:
PPCANSI.o
PPCunix.o
PPCRuntime.o
InterfaceLib.xcoff
MathLib.xcoff
• for C++ code only, the CodeWarrior library:
PPCIOStreams.o
PPCCPlusLib.o
• C++ ANSI conformance UNCHECKED (C++ only)
In addition, if you compile a stand-alone FORTRAN program (instead of only some FORTRAN subroutines) you must include F2Cmain.c in your project (or F2Cmain.cp if you use C++; the two files are identical). This is because the original main routine in the FORTRAN program becomes a function that is called by F2Cmain.c. In addition, F2Cmain.c performs a series of initializations (primarily related to error catching) prior to executing the main FORTRAN program.
The model project provided (SPM Mac F2C C Project) is a folder that contains everything you need to compile and run code produced by Mac F2C using the C compiler. This folder has a copy of F2Cmain.c, f2c.h, and a project file that includes the appropriate libraries and option settings.
The C++ model project (SPM Mac F2C C++ Project) is a folder that contains everything you need to compile and run code produced by Mac F2C using the C++ compiler. This folder has a copy of F2Cmain.cp, f2c.h, and a project file that includes the appropriate libraries and option settings.
Create a new project by using the New Project command in the Symantec Project Manager’s File menu and selecting SPM Mac F2C C Project or SPM Mac F2C C++ Project as the model for the new project. Add your code files as appropriate, bring it up-to-date (you may need to use the Make command and the Use Disk option the first time), and run.
If you compile a FORTRAN subroutine or function that you want to call from a C program, look at the output C code to see the appropriate calling protocol. You may or may not need to include the F2C support libraries (libF77 and libI77). In rare cases, you may also need to copy some of the initialization code from F2Cmain.c to your calling program.
I urge all users to read the enclosed AT&T Computing Science Technical Report No. 149. Consider it your compiler and language reference manual. You can print the report by downloading it to any PostScript printer. You can use Apple’s LaserWriter Utility application to do this or you can use any of the many equivalent utilities.